<?php

namespace App\Trip\Plane\Interfaces\Result\Wrappers;

use App\Trip\Plane\Interfaces\Result\Abstracts\AbstractFlightQueryResult;
use App\Trip\Plane\Requests\TicketQueryRequest;
use Illuminate\Support\Collection;

class PlaneQueryResultPaginatorWrapper extends AbstractFlightQueryResult
{
    private TicketQueryRequest        $request;
    private Collection                $lists;
    private AbstractFlightQueryResult $res;

    public function __construct(AbstractFlightQueryResult $res, TicketQueryRequest $request)
    {
        $this->res     = $res;
        $this->lists   = $res->getLists();
        $this->request = $request;
    }

    public function getLists(): Collection
    {
        return $this->lists->forPage($this->getPage(), $this->getPageSize())->values();
    }

    public function getPage(): int
    {
        return $this->request->page();
    }

    public function getPageSize(): int
    {
        return $this->request->page_size();
    }

    public function getCount(): int
    {
        // 返回原始数据的总数量
        return $this->res->getCount();
    }
}